#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from lib import publics


def login():
    print("登陆模块")


def register():
    username = input("请输入用户名: ").strip()
    pwd = input("请输入密码: ").strip()
    if username != "" or pwd != "":
        res = "创建成功" if publics.write_db(username, pwd) else "用户存在"
        print(res)


def shopping():
    print("购物模块")


def loggin():
    print("日志模块")


mode_list = {
    1: login,
    2: register,
    3: shopping,
    4: loggin,
}


def run():
    while True:
        print("\n1、登陆\n2、注册\n3、购物\n4、日志\n5、退出")
        try:
            chiose = int(input(">>>>>").strip(""))
        except:
            print("输入错误")
            continue
        if chiose > len(mode_list) + 1:
            print("没有这个选项")
            continue
        elif chiose == 5:
            print("退出")
            break
        else:
            mode_list[chiose]()
